import { getRoles } from '@/utils/userInfo';

export default {
  TYPE: {
    CREATE: 'CREATE',
    EDIT: 'EDIT',
    DISPLAY: 'DISPLAY',
    SEARCH: 'SEARCH',
  },
  METATYPE: {
    column : 'column',
    button : 'button',
    table_button : 'table_button',
    search_column : 'search_column',
    table_column : 'table_column',
    search_button : 'search_button',
  },
  METHOD: {
    POST: 'POST',
    GET: 'GET',
  },
  SEARCH: 'SEARCH',
  DSM_SPLIT: '_',
  DSM_PREFIX: 'DSM_',
  DSA_PREFIX: 'DSA_',
  MODEL_ARRAY: 'modelArray',
  TO_ARRAY: (json: any) => {
    const array = [];
    for (let k in json) {
      if (k === 'id' || k === 'enabled' || k === 'isSearch') continue;
      array.push(json[k]);
    }
    return array;
  },
  isAdmin: () => {
    return getRoles().includes('ADMIN');
  },
};
